package com.example.mes.config;


import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Swagger2配置信息
 */
@Configuration
@EnableSwagger2
public class Swagger2Config {
    @Bean
    public Docket webApiConfig(){

        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("AdminApi")
                .apiInfo(webApiInfo())
                .enable(true) //开启，生产环境隐藏
                .select()
                //只显示api路径下的页面
                .apis(RequestHandlerSelectors.basePackage("com.example.mes.web.controller"))
                .build();
    }
    private ApiInfo webApiInfo(){

        return new ApiInfoBuilder()
                //设置文档标题(API名称)
                .title("MES系统接口管理-API文档")
                //文档描述
                .description("接口说明")
                //服务条款URL
//                .termsOfServiceUrl("http://localhost:8881/")
                .version("1.0.0")
                .build();
    }
}
